function checkToken({
	cbIfHasToken = null,
	pathForGoingBack = "",
	isTabBarPage = true
} = {}) {
	// 找缓存有没有token
	let token = uni.getStorageSync('token')
	if (token) {
		cbIfHasToken()
	} else {
		// 没有token
		uni.switchTab({
			url: '/pages/user/user',
			success: () => {
				// 把当前路径存储起来，登录之后可以跳转回去
				uni.setStorageSync('pathForGoingBack', pathForGoingBack)
				// 页面路径类型，为了区分是tabBar页面还是普通页面，二者跳转方式不同
				uni.setStorageSync('isTabBarPage', isTabBarPage)
			}
		})
	}
}

function goBackAfterLogin() {
	let pathForGoingBack = uni.getStorageSync('pathForGoingBack')
	let isTabBarPage = uni.getStorageSync('isTabBarPage')
	if (pathForGoingBack) {
		if (isTabBarPage) {
			uni.switchTab({
				success: () => {
					uni.removeStorageSync('pathForGoingBack')
					uni.removeStorageSync('isTabBarPage')
				}
			})
		} else {
			uni.redirectTo({
				url: pathForGoingBack,
				success: () => {
					uni.removeStorageSync('pathForGoingBack')
					uni.removeStorageSync('isTabBarPage')
				}
			})
		}
	}
}

export {
	checkToken,
	goBackAfterLogin
}
